package dashboard.constant;


/**
 * 
 * 平台
 * 
 * <p>
 * detailed comment
 * 
 * @author guolu 2015-1-26
 * @see
 * @since 1.0
 */
public enum EnumPlatform {

	all, pc, m, app;

	public String getColName() {
		switch (this) {
		case all:
			return "all";
		case pc:
			return "pc";
		case m:
			return "m";
		case app:
			return "app";
		default:
			return "all";
		}
	}
	

	private static final String PATTEN_PLATFORM = "business_name in('all','%s') AND page_type='%s' GROUP BY %s";

	/**
	 * 获取某 “业务线三端流量各自占总三端流量” 的比值 查询条件
	 * @param cate
	 * @return
	 * @author zhaoxiang 2015-04-22
	 */
	public static String getPlatformRateCon(NetFlowIndex index, EnumCate cate,String groupBy) {
		switch (index) {
		case vppv:
			return String.format(PATTEN_PLATFORM, cate.getDBName(), EnumPageType.detail.getDBName(), groupBy);
		case lide_pv:
			return String.format(PATTEN_PLATFORM, cate.getDBName(), EnumPageType.listanddetail.getDBName(), groupBy);
		case lide_uv:
			return String.format(PATTEN_PLATFORM, cate.getDBName(), EnumPageType.listanddetail.getDBName(), groupBy);
		default:// pv , uv
			return String.format(PATTEN_PLATFORM, cate.getDBName(), EnumPageType.total.getDBName(), groupBy);
		}

	}	
	
	/**
	 * 获取某 “业务线三端流量各自占总三端流量” 的比值 查询列
	 * @param cate
	 * @return
	 * @author zhaoxiang 2015-04-22
	 */
	public static String getPlatRateColumn(NetFlowIndex index,  EnumCate cate, String groupBy) {

		switch (index) {
			case pv:
			case vppv:
			case lide_pv:
				return groupBy+",SUM(if(business_name='"+cate.getDBName()+"',pv,0))*10000/SUM(if(business_name='all',pv,0)) as pv";
			case uv:
			case lide_uv:
				return groupBy+",SUM(if(business_name='"+cate.getDBName()+"',uv,0))*10000/SUM(if(business_name='all',uv,0)) as uv";
			default:
				return "";
		}
	}
	
}
